/*
 * Project: Sudoku Hint Engine for Android
 * Copyright (C) 2010-2013 Emanuel Moecklin
 * 
 * Available under the terms of the Lesser General Public License (LGPL)
 */
package com.onegravity.sudoku.solver.checks;

import com.onegravity.sudoku.solver.accumulator.HintsAccumulator;
import com.onegravity.sudoku.solver.accumulator.StopHintProductionException;
import com.onegravity.sudoku.solver.data.Grid;

/**
 * This class checks that all pencil marks are correct.
 * A cell's pencil marks are correct if none contradicts other cells (value already in same row, column or block)
 * and if the correct value is part of the cell's pencil marks.
 * @author Emanuel Moecklin
 */
public class IncorrectPencilMarksProducer extends PencilMarksHintsProducer {

	public IncorrectPencilMarksProducer(Grid solvedGrid) {
		super(solvedGrid);
	}

	@Override
	public void getHints(Grid grid, HintsAccumulator accu) throws StopHintProductionException {
		if (!processGrid(grid) && (mToBeAdded.size()>0 || mToBeRemoved.size()>0)) {
			// some missing or just incorrect
			IncorrectPencilMarksWarning message = new IncorrectPencilMarksWarning(grid, mToBeAdded, mToBeRemoved);
            accu.add(message);
		}
    }
}